<!doctype html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<title>Message</title>
		<meta name="description" content="" />
		<meta name="keywords" content="" />
		<link rel="stylesheet" type="text/css" href="/statics/css/index.css" th:href="@{/statics/css/index.css}" media="all" />
	</head>

	<body class="home blog custom-background round-avatars">
	<div th:replace="~{common/rept2::sider2}"></div>
	<div th:replace="~{common/repitation::header}"></div>
		<div id="main" class="content">

			<div class="container">

				<div class="table-responsive">
					<table class="table table-striped table-sm">
						<thead>
						<tr>
							<th>昵称</th>
							<th>email</th>
							<th>message</th>
							<th>日期</th>
							<th>操作</th>
						</tr>
						</thead>
						<tbody>
						<tr th:each="message:${messages}">
							<td th:text="${message.messageNickname}"></td>
							<td th:text="${message.messageEmail}"></td>
							<td th:text="${message.messageText}"></td>
							<td th:text="${#dates.format(message.messageDate,'yyyy/MM/dd')}"></td>
							<td>
								<form th:action="@{/message/}+${message.messageId}" method="post">
									<input type="hidden" name="_method" value="delete">
									<input type="hidden" name="id" th:value="${message.messageId}">
									<button class="btn btn-sm btn-danger">删除</button></form>

							</td>
						</tr>
						</tbody>
					</table>
				</div>
			</div>

			<!--					分页显示-->
			<div class="pagination js-pagination">
				<div class="js-next pagination__load">
					<script type="text/javascript" th:src="@{/jquery.min.js}"></script>
					<style>
						a{cursor:pointer;}
						a:hover{color:green;}
						a.active{color:red;}
					</style>
					<a name="pageNum" class="allpage"><b th:text="'共 '+ ${pages.getTotalPages()}+ ' 页'"></b></a>
					<a  th:if="${pages.hasPrevious()} == true" th:href="@{/main/message(currentPage=${pages.previousPageable().getPageNumber()})}"  >上一页</a>
					<a name="pageNum" th:href="@{/main/message(currentPage=${i})}"  th:each="i :${#numbers.sequence(0, pages.getTotalPages()-1)}" th:text="${i+1}" th:class="${pages.getNumber()==i}?'active'" th:if="${i}<3" ></a>
					<a th:text="..."  th:if="${pages.getTotalPages()}>2"></a>
					<a th:text="${pages.getNumber()+1}" th:class="active" th:if="${pages.getNumber()}>2"></a>


					&nbsp;&nbsp;<a name="pageNum" th:if="${pages.hasNext()} == true"  th:href="@{/main/message(currentPage=${pages.nextPageable().getPageNumber()})}" >下一页</a>
					&nbsp;&nbsp;<a th:href="@{'/main/message?currentPage='+ ${pages.getTotalPages()-1}}" >尾页</a>
					<script>
						$("a").click(function(){
							$(this).addClass("active").siblings().removeClass("active");
						})
					</script>
				</div>
			</div>
		</div>


	<div th:replace="~{common/repitation::footer}"></div>
	</body>

</html>